var http = require('../../utils/http.js');
Page({
	data: {
		addressList: [],
		icon: 'roundcheckfill',
		indexId: "",
		radio: 0,
	},
	handleClick(e) {
		console.log(e);
		this.setData({
			indexId : e.currentTarget.dataset.index,
			radio: e.detail,
		})
		// if(this.indexId==index){
		// 	this.indexId='3122313'
		// }else{
		// 	this.indexId=index
		// }
		wx.showLoading({});
		http.request({
			url: `/p/address/defaultAddr/${e.currentTarget.dataset.item}`,
			method: "put",
			data: {
				addrId: e.currentTarget.dataset.item
			},
			callBack: res => {
				wx.hideLoading();
			}
		})
	},
	handleEdit(e) {
		wx.navigateTo({
			url: `/pages/editAddress/editAddress?addrId=${e.currentTarget.dataset.item}`
		})
	},
	handleAdd() {
		wx.navigateTo({
			url: '/pages/editAddress/editAddress'
		})
	},
	handleSearve() {
		http.request({
			url: "/p/address/list",
			method: "get",
			data: {},
			callBack: res => {
				this.setData({
					addressList : res
				})
				// console.log(this.addressList);
				// console.log(this.swiperList, "232431");
			}
		})
	},
	onLoad: function () {
		this.handleSearve()
	},
	onShow: function() {
		this.handleSearve()
	}
})